package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.SettlementsRule;
import com.eling.elcms.travel.service.ISettlementsRuleManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
@Controller
public class SettlementsRuleController extends BaseFormController{

	@Autowired
	private ISettlementsRuleManager settlementsRuleManager;
	
	@RequestMapping("/api/cashbackrule/save")
    @ResponseBody
	public SettlementsRule save(@ModelAttribute@ModelFilling SettlementsRule data){
		return settlementsRuleManager.save(data);
	}
	
	@RequestMapping("/api/cashbackrule/{pkSettlementsRule}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkSettlementsRule){
		settlementsRuleManager.remove(pkSettlementsRule);
		return new Msg("删除成功");
	}
	
	@RequestMapping("/api/cashbackrule/query")
    @ResponseBody
	public List<SettlementsRule> query(@ModelAttribute SettlementsRule settlementsRule){
		return settlementsRuleManager.query(settlementsRule);
	}
	
	@RequestMapping("/api/cashbackrule/search*")
	@ResponseBody
	public List<SettlementsRule> search(@ModelAttribute SearchCondition sc,@ModelAttribute SettlementsRule settlementsRule){
		sc.setQueryCondition(settlementsRule);
		return settlementsRuleManager.search(sc);
	}
}

